using System.Net.Mime;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;

namespace SocketTool.Views.DialogWindows
{
    public partial class MessageDialogWindow : Window
    {
        private string _tips = string.Empty;

        public MessageDialogWindow()
        {
            InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
        }
        public MessageDialogWindow(string tips)
        {
            this._tips = tips;
            InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif

            this.Opened += (s, e) =>
            {
                txt_Tips = this.FindControl<global::Avalonia.Controls.TextBlock>("txt_Tips");
                txt_Tips.Text = this._tips;
            };
            // this.Activated += (s, e) => { this.txt_Tips.Text = this._tips;};
        }


        private void InitializeComponent()
        {
            AvaloniaXamlLoader.Load(this);
        }

        private void Button_OnClick(object? sender, RoutedEventArgs e)
        {
            this.Close();
        }


        static public void ShowTipsDialog(string tips)
        {
            new MessageDialogWindow(tips).ShowDialog(App.MainWindow);
        }
    }
}